package study.apm.prometheus.controller;

import io.micrometer.core.instrument.Counter;
import io.micrometer.core.instrument.Gauge;
import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.Tags;
import io.micrometer.core.instrument.Timer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/metric")
public class MetricController {

    @Autowired
    private MeterRegistry meterRegistry;

    @RequestMapping("/counter")
    public void test() {
        Counter counter = Counter.builder(">>>>>> aaaaa <<<<<<")
                .description("这是一个指标描述")
                .tags(Tags.of("method", ""))
                .register(meterRegistry);
        counter.increment();
    }

    @RequestMapping("/gauge")
    public void gauge() {
        Gauge gauge = Gauge.builder("****** bbbbbbbbb *******", () -> 100L)
                .description("")
                .tag("", "")
                .register(meterRegistry);
    }

    @RequestMapping("/summary")
    public void summary() {
    }

    @RequestMapping("/timer")
    public void timer() {
        Timer timer = Timer.builder("")
                .description("")
                .tag("", "")
                .register(meterRegistry);
    }
}
